#ifndef _ANIM_H_
#define _ANIM_H_

#include "ship.h"

enum {
    ANIM_ROTATE_SHIP,
    ANIM_MOVE_SHIP,
    ANIM_SEQUENCE,
    ANIM_PARALLEL,
};

typedef struct AnimRotateShip {
    Ship* ship;
    int start_direction;
    int n_direction;
    int clockwise;
    unsigned int time;
} AnimRotateShip;

typedef struct AnimMoveShip {
    Ship* ship;
    int x_start;
    int y_start;
    int x_offset_start;
    int y_offset_start;
    int len_end;
    int len;
    unsigned int time;
} AnimMoveShip;

struct Anim;

typedef struct AnimSequence {
    struct Anim* first;
    struct Anim* second;
} AnimSequence;

typedef struct AnimParallel {
    struct Anim* first;
    struct Anim* second;
} AnimParallel;

typedef union AnimUnion {
    AnimRotateShip rotate_ship;
    AnimMoveShip move_ship;
    AnimSequence sequence;
    AnimParallel parallel;
} AnimUnion;


typedef struct Anim {
    int type;
    AnimUnion anim;
} Anim;

Anim* InitAnimRotateShip(Ship* ship, int direction_end);
Anim* InitAnimMoveShip(Ship* ship, int direction, int offset);
Anim* InitAnimSequence(Anim* anim_first, Anim* anim_second);
Anim* InitAnimParallel(Anim* anim_first, Anim* anim_second);
int UpdateAnim(Anim* anim, int delta_ticks);
void DestroyAnim(Anim** anim);

#endif /* _ANIM_H_ */
